# -*- coding: utf-8 -*-

# from __future__ import unicode_literals

import os


def translate_line(keys, mod, line):
    """翻译模块mod下文件中的一行文本
        需要人工审查的内容：js中的翻译部分，需要人工补充'this.'
        # = "key" -> this.$t(`m.{mod}['{key}']`).format(mod=mod, key=key)
        # = 'key' -> this.$t(`m.{mod}["{key}"]`).format(mod=mod, key=key)

        翻译方法：
            1、获取翻译表d, m[mod]
            2、逐行查找d中的所有key并进行替换
            3、替换原则：
                "key" -> {{$t(`m.{mod}['{key}']`).format(mod=mod, key=key)}}
                'key' -> {{$t(`m.{mod}["{key}"]`).format(mod=mod, key=key)}}

                :placeholder="key" -> "$t(`m.{mod}["{key}"]`).format(mod=mod, key=key)"
                "key" -> $t(`m.{mod}['{key}']`).format(mod=mod, key=key)
                'key' -> $t(`m.{mod}["{key}"]`).format(mod=mod, key=key)
    """

    IS_ATTRIBUTE = (
        "<" in line
        or ">" in line
        or "placeholder=" in line
        or "content=" in line
        or "confirm=" in line
        or "cancel=" in line
        or "title=" in line
    )

    for k in keys:

        TRANS_FUNC = "$t"

        # 避免重复翻译
        if TRANS_FUNC not in line and k in line:

            # 中文作key，跳过翻译
            k51 = "'%s':" % k
            k52 = '"%s":' % k

            if k51 in line or k52 in line:
                continue

            k1 = ">"
            k2 = "</"

            k12 = ">{}</".format(k)

            # 区分单双引号包裹
            k3 = "'%s'" % k
            k31 = ": '%s'" % k
            k32 = "= '%s'" % k
            k33 = ", '%s'" % k
            k4 = '"%s"' % k
            k41 = ': "%s"' % k
            k42 = '= "%s"' % k
            k43 = ', "%s"' % k

            # 区分标签中的翻译、属性中的翻译、js表达式中的翻译
            if k12 in line:
                new_key = "{{ $t(`m.%s['%s']`) }}" % (mod, k)
            elif k1 in line and k2 in line:
                wk = "'{}'".format(k)
                if wk in line:
                    k = wk

                if "{{" in line or "v-" in line or ("?" in line and ":" in line) or (":" in line and "," in line):
                    new_key = "$t(`m.%s[%s]`)" % (mod, wk)
                else:
                    new_key = "{{ $t(`m.%s[%s]`) }}" % (mod, wk)
            elif k3 in line:
                k = k3
                # 属性和表达式中的翻译需要带：this.
                if k31 in line or k32 in line or k33:
                    if IS_ATTRIBUTE:
                        if "?" in line and ":" in line:
                            new_key = "$t(`m.%s[%s]`)" % (mod, k3)
                        else:
                            new_key = '"$t(`m.%s[%s]`)"' % (mod, k3)
                    else:
                        new_key = "this.$t(`m.%s[%s]`)" % (mod, k3)
                else:
                    new_key = "'$t(`m.%s[%s]`)'" % (mod, k3)

            elif k4 in line:
                k = k4
                if k41 in line or k42 in line or k43:
                    if IS_ATTRIBUTE:
                        new_key = '"$t(`m.%s[%s]`)"' % (mod, k3)
                    else:
                        new_key = "this.$t(`m.%s[%s]`)" % (mod, k3)
                else:
                    new_key = '"$t(`m.%s[%s]`)"' % (mod, k3)
            else:
                new_key = k

            line = line.replace(k, new_key)

            # 打印变化的位置
            if new_key != k:
                print(mod, k, new_key, "-------\n", line)

            if TRANS_FUNC in line:
                if 'title="$t' in line:
                    line = line.replace("title=", ":title=")

                if 'confirm="$t' in line:
                    line = line.replace("confirm=", ":confirm=")

                if 'cancel="$t' in line:
                    line = line.replace("cancel=", ":cancel=")

                if 'content="$t' in line:
                    line = line.replace("content=", ":content=")

                if 'placeholder="$t' in line:
                    line = line.replace("placeholder=", ":placeholder=")

                if 'start-placeholder="$t' in line:
                    line = line.replace("start-placeholder=", ":start-placeholder=")

                if 'end-placeholder="$t' in line:
                    line = line.replace("end-placeholder=", ":end-placeholder=")

    return line


def translate_file(mod, parent_dir, files, scopes=None):
    """翻译模块mod下的所有文件files
        比如：mode=home,翻译src/views/home下的所有文件
    """

    # print mod, files
    # print os.path.curdir
    trans_table = get_transtable(mod)

    # 从长到短翻译，避免局部先翻译
    keys = list(trans_table.keys())
    keys.sort(cmp=lambda x, y: len(y) - len(x))
    # print '---------------------------------------'
    # for key in keys:
    #     print key
    # print '---------------------------------------'

    for file_name in files:

        if scopes and mod not in scopes:
            print("skip file: %s" % file_name)
            continue

        file_path = os.path.join(os.path.curdir, parent_dir, file_name)
        if os.path.splitext(file_name)[-1] not in [".vue", ".js"]:
            # print 'skip file: %s' % file_path
            continue

        print("translate file: %s" % file_path)
        with open(os.path.join(os.path.curdir, parent_dir, file_name), "r+") as f:
            file_lines = f.readlines()
            f.seek(0, 0)
            for line in file_lines:
                line = translate_line(keys, mod, line)
                f.write(line)


def get_transtable(mod):
    return {
        "common": {
            "不合法或者重复输入，请检查。": "Illegal or repetitive input, please check.",
            "提交": "Submit",
            "保存模板": "Save templates",
            "更新模板": "Update template",
            "取消": "Cancel",
            "模板名称": "Template name",
            "请输入模板名称": "Please enter the template name",
            "确认更新模板": "Confirm update template",
            "更新模板操作将会覆盖原先模板的信息": "Updating the template will overwrite the information of the original template",
            "为必填项，请补充完善": "Please complete the required items.",
            "无字段可以保存": "No field can be saved",
            "更新成功": "Updated successfully",
            "模板名称为必填项": "Template name is required",
            "保存成功": "Saved successfully",
            "请选择所属的厅委办": "Please select the office to which you belong",
            "请选择所属业务": "Please choose your business",
            "添加": "Add",
            "删除": "Delete",
            "默认行不能删除": "Default rows cannot be deleted",
            "确认要删除此条数据": "Confirm that you want to delete this data",
            "选择日期": "Choose a date",
            "选择日期时间": "Choose the date and time",
            "添加收藏": "Add to Collection",
            "取消收藏": "Cancel to Collection",
            "无数据": "No Data",
            "指南": "Guide",
            "组件": "Component",
            "单选框": "Radio",
            "请选择服务目录": "Please select the service directory",
            "我的收藏": "My Collection",
            "清空": "Clear",
            "赋值1": "Assignment1",
            "赋值2": "Assignment2",
            "是否使用模板": "Use templates?",
            "使用模板可以快速填写字段信息": "Use templates to fill in field information quickly",
            "提交成功": "Submitted successfully",
            "打印日期": "Print date",
            "打印人": "Printer",
            "状态": "Status",
            "打印本页": "Print this page",
            "一、工单信息": "I. Worksheet Information",
            "提单时间": "Submission time",
            "提单人": "Submitter",
            "服务目录": "Service catalogue",
            "见表格": "See the table for details.",
            "表格": "Table",
            "二、工作流": "II.Workflow",
            "结束": "End",
            "处理": "Handle",
            "处理操作": "Processing operations",
            "请勾选需要导出的字段": "Check the fields you want to export",
            "全选": "Selete All",
            "选中": "Seleted",
        },
        "deployPage": {
            "流程设计": "Process design",
            "新增": "Add",
            "新增流程": "Add process",
            "导入": "Import",
            "说明": "Instructions",
            "类型": "Type",
            "更新人": "Updater",
            "更新时间": "Update at",
            "状态": "Status",
            "操作": "Operations",
            "编辑": "Edit",
            "部署": "Deploy",
            "预览": "Preview",
            "导出": "Export",
            "删除": "Delete",
            "暂无数据": "No Data",
            "共计": "Total",
            "条": "",
            "页": "pages",
            "部署流程名": "Name of Deployment process",
            "请输入部署流程名": "Please enter the name of the deployment process",
            "部署流程名不能为空": "Name of Deployment process cannot be empty",
            "流程预览": "Process preview",
            "流程名": "Process name",
            "请输入流程名": "Please enter the process name",
            "请选择流程类型": "Please select the process type",
            "请输入更新人": "Please enter an updater",
            "启用状态": "Enabled status",
            "请选择启用状态": "Please select the enabled status",
            "草稿": "Draft",
            "关闭": "Close",
            "启用": "Enable",
            "确认部署": "Confirm deploy",
            "成功导入": "Import successfully",
            "个流程": "processes",
            "失败": "failed",
            "文件大小不能超过10MB": "File size should not exceed 10MB",
            "流程部署成功，请关联服务后使用": "Process deployment successfully, use after associated services",
            "流程一旦删除，将无法还原，请谨慎操作": "Once the process is deleted, it will not be restored. Please operate with caution.",
            "确认删除此流程": "Confirm to delete this process",
            "删除流程成功": "Delete process successfully",
            "流程名称": "Process name",
            "请输入流程名称": "Please enter the process name",
            "流程名称不能为空且最长不超过20个字": "The process name should not be empty and should not exceed 20 words at most.",
            "流程类型": "Process type",
            "流程类型不能为空": "Process type cannot be empty",
            "是否关联业务": "Associated with business",
            "流程说明": "Process instructions",
            "请输入流程说明，最多能输入100个字": "Please enter a process instructions, up to 100 words.",
            "流程说明最多能输入100个字": "The process instructions can input up to 100 words.",
            "返回": "Return",
            "保存": "Save",
            "保存成功": "Saved successfully",
            "定义与配置流程": "Definite and configurate process",
            "更多筛选条件": "More screening conditions",
            "选择日期时间": "Choose the date and time",
            "查询": "Query",
            "清空": "Clear",
            "新增设计流程": "New design process",
            "配置节点": "Configurate node",
            "流程设计：流程修改后，需要重新部署才能使改动生效": "Process design: Changing a process requires deploying a modified process to make the process effective",
            "填写流程信息": "Fill in process information",
            "流程启用设置": "Process Enablation Settings",
        },
        "eventdeploy": {
            "SLA管理": "SLA Management",
            "新增": "Add",
            "名称": "Name",
            "级别": "Level",
            "说明": "Instructions",
            "响应时间要求": "Response time requirements",
            "解决时间要求": "Resolve time requirements",
            "操作": "Operations",
            "收缩": "shrink",
            "小时": "Hours",
            "分钟": "Minutes",
            "天": "days",
            "编辑": "Edit",
            "保存": "Save",
            "取消": "Cancel",
            "暂无数据": "No Data",
            "请输入SLA名称": "Please enter the SLA name",
            "请填写SLA说明，最多能输入150个字": "Please fill in the SLA instructions and enter up to 150 words.",
            "响应时长要求": "Response time requirements",
            "解决时长要求": "Resolve time requirements",
            "确认": "Confirm",
            "关闭": "Close",
            "新增SLA": "New SLA",
            "请完善要填写的信息": "Please complete the information to be filled in.",
            "级别名称不能超过8个字": "Level names should not exceed 8 words",
            "描述不能少于5个字": "Description should not be less than five words",
            "描述不能超过150个字": "Description should not exceed 150 words",
            "响应时长不能超过1000": "Response time should not exceed 1000",
            "解决时长不能超过1000": "Solution time should not exceed 1000",
        },
        "flowManager": {
            "版本号": "Version number",
            "流程名": "Process name",
            "流程类型": "Process type",
            "发布人": "Publisher",
            "发布时间": "Published time",
            "关联服务数": "Number of associated services",
            "操作": "Operations",
            "暂无数据": "No Data",
            "流程版本": "Process version",
            "由流程模版发布后即可生成": "It can be generated after the process template is published.",
            "批量删除": "Batch delete",
            "预览": "Preview",
            "还原": "Reduction",
            "删除": "Delete",
            "已有流程": "Existing processes",
            "标题": "Title",
            "类型": "Type",
            "确认删除此流程": "Confirm to delete this process",
            "流程预览": "Process preview",
            "流程删除确认": "Process deletion confirmation",
            "流程还原确认": "Process Recovery confirmation",
            "流程导出确认": "Process export confirmation",
            "流程批量删除确认": "Process batch deletion confirmation",
            "请确认已经解绑当前流程版本关联的服务": "Make sure that the services associated with the current process version are unbound",
            "还原后请移步到流程设计处编辑": "After restoring, please move to the process design office to edit",
            "确认后将导出当前版本的流程数据为JSON格式的文件": "After confirmation, the current version of the process data will be exported to JSON format file",
            "请确认已经解绑选中的流程版本关联的服务": "Please confirm that the service associated with the selected process version has been unbounded",
            "批量删除成功": "Batch deleted Successfully",
            "删除成功": "Deleted Successfully",
            "成功还原该流程，请前往【流程设计】查看": "Successfully restore the process, please go to [Process Design] to see",
        },
        "home": {
            "基础配置": "Basic configuration",
            "您尚未设置附件存放的目录，请填写": "You have not set up a directory for attachments. Please fill in the form.",
            "当前存放附件文件的目录为": "The current directory for storing attachment files is",
            "更改位置": "Modify location",
            "提交": "Commit",
            "保存": "Save",
            "附件存储": "Accessory storage",
            "请管理员配置合法的文件存储路径，并保证每台应用服务器都能够访问该目录（可配置nfs等共享目录）": "Ask administrators to configure legitimate file storage paths and ensure that each application server has access to the directory (configurable shared directories such as nfs)",
            "若需要更换目录，请务必将原来目录中的文件拷贝到新的目录，并建议对附件目录做定期备份。": "If you need to change the directory, you must copy the files from the original directory to the new directory. It is recommended that the attachment directory be backed up regularly.",
            "清除缓存": "Clear cache",
            "缓存内容": "Cached content",
            "业务列表缓存": "Business list cache",
            "业务角色及人员列表缓存": "Business roles and member list caching",
            "一键清除": "One-click clearance",
            "上次清除时间": "Last clearance time",
            "缓存清除": "Cache clearance",
            "如需即时更新来自CMDB的最新数据，可以通过手动清除缓存获取最新数据。": "If you need to update the latest data from CMDB in real time, you can get the latest data by manually clearing the cache.",
            "组织架构功能开关": "Organizational Architecture Functional Switch",
            "组织架构功能依赖以下服务，请确认依赖可用后开启：": "Organizational architecture functions depend on the following services. Make sure that dependencies are available and open:",
            "蓝鲸用户管理": "Blue King User Management",
            "是否启用该功能：": "Enable this function:",
            "打开": "Open",
            "关闭": "Close",
            "组织架构功能开关：": "Organizational Architecture Function Switch:",
            "组织架构功能依赖蓝鲸平台其他服务（用户管理），若依赖不可用，将无法启用本功能。": "The organizational architecture function relies on other services of Blue Whale Platform (user management). If the dependence is not available, this function will not be enabled.",
            "暂无": "No data",
            "请填写路径": "Please fill in the path.",
            "请添加存储位置": "Please add storage location",
            "更新成功": "Updated Successfully",
            "清除缓存成功": "Cache Cleared Successfully",
            "启用成功": "Enabled successfully",
            "关闭成功": "Closed successfully",
            "共": "Total",
            "条": "",
            "每页显示": "Display per page",
            "请勾选要导出的字段": "Check the fields you want to export",
            "全局视图": "Global view",
            "回转链接参数custom": "Rotary link parameters",
            "前天": "The day before yesterday",
            "最近五天": "The last five days",
            "请选择": "Please choose",
            "流程": "Process",
            "申请": "Applications ",
            "请选择服务": "Please choose the service.",
            "提单申请": "Application for submit worksheet",
            "整体工单视图": "Overall worksheet view",
            "工单处理排行": "Worksheet processing ranking",
            "工单认领排行": "Worksheet take ranking",
            "工单派单量": "Worksheet quantity",
            "初始月份": "The initial month",
            "截止月份": "By the month",
            "=当前处于结束状态的单/当前总单量*100%": "=Current finished worksheets/current total worksheets*100%",
            "变更": "Change",
            "故障": "Fault",
            "问题": "Problems",
            "请求": "Requests",
            "工单量": "Worksheet quantity",
            "每日新增单量": "Daily new worksheet",
            "工单耗时": "Worksheet consume time",
            "满意度": "Satisfaction",
            "最近一周": "In the latest week",
            "最近一个月": "Last month",
            "最近三个月": "Last 3 months",
            "状态分布": "Status distribution",
            "单量TOP10排行": "Worksheet quantity TOP10 ranking",
            "每月关单率": "Monthly clearance rate",
            "整体关单率": "Overall closing rate",
            "选择时间超过当前时间": "Select time over current time",
            "截止时间应不小于初始时间": "The cut-off time should be no less than the initial time",
            "所有": "All",
            "已完成": "Finished",
            "未完成": "Failed",
            "解决时长": "Solving time",
            "响应时长": "Response time",
            "平均解决时长": "Average resolve time",
            "平均响应时长": "Average response time",
            "周五": "Friday",
            "星": "Star",
            "快速提单": "Quick Submit",
            "总单量": "The total amount of worksheets",
            "最新动态": "News",
            "处理过的单据": "Processed worksheets",
            "单据处理总耗时": "Total worksheet processing Time-consuming",
            "当前单据状态分布占比": "Current worksheet status distribution proportion",
            "腾讯蓝鲸 版权所有": "Tencent BlueKing Copyright All Rights Reserved",
            "请求申请": "Request for application",
            "暂无动态": "No dynamic",
            "您目前还没有新动态更新": "You don not have any new dynamic updates yet.",
            "最近7天": "The last 7 days",
            "今天": "Today",
            "最近30天": "Recent 30 days",
            "待办列表": "To-do list",
            "选择了": "Selected",
            "总计": "Total",
            "单量": "Worksheet quantity",
            "耗时占比": "Time-consuming proportions",
            "单据占比": "Worksheet proportions",
            "类型": "Type",
            "请选择工单类型": "Please choose the type of worksheet.",
            "请输入单号": "Please enter the worksheet ID",
            "状态": "Status",
            "请选择单据状态": "Please select the worksheet status.",
            "开始日期": "Start date",
            "结束日期": "End date",
            "查询": "Query",
            "清空": "Clear",
            "服务目录": "Service catalogue",
            "请输入单号/标题": "Please enter a worksheet ID/title.",
            "更多筛选条件": "More screening conditions",
            "提交需求": "Submitting Requirements",
            "所有工单": "Total worksheet",
            "我的待办单": "My to-do worksheets",
            "我的历史单": "My History worksheets",
            "单号": "Worksheet ID",
            "标题": "Title",
            "工单类型": "Worksheet type",
            "提单人": "Submitter",
            "提单时间": "Submission time",
            "暂无数据": "No Data",
        },
        "manageCommon": {
            "提交": "Submit",
            "取消": "Cancel",
            "服务目录": "Service catalogue",
            "服务": "Service",
            "请选择服务": "Please choose the service.",
            "服务说明": "Service instructions",
            "收藏成功": "Collected successfully",
            "取消成功": "Cancelled successfully",
            "单号": "Worksheet ID",
            "标题": "Title",
            "类型": "Type",
            "提单人": "Submitter",
            "提单时间": "Submission time",
            "状态": "Status",
            "当前步骤": "Current step",
            "操作": "Operations",
            "满意度评价": "Satisfaction Evaluation",
            # '处理': 'Handle',
            "查看": "Check",
            "暂无数据": "No Data",
        },
        "managePage": {
            "所有单据": "All worksheets",
            "我的待办": "My to-do Worksheets",
            "我的申请单": "My application Worksheets",
            "我的历史单": "My History Worksheets",
            "新增": "Add",
            "单号/标题": "Worksheet ID/Title",
            "导出": "Export",
            "更多筛选条件": "More screening conditions",
            "共": "Total",
            "每页显示": "Display per page",
            "最近一周": "Last week",
            "最近一个月": "Last month",
            "最近三个月": "The last three months",
            "请勾选要导出的字段": "Check the fields you want to export",
            "申请": "Applications",
            "一级": "Class A",
            "二级": "Class B",
            "三级": "Class C",
            "请选择": "Please select",
        },
        "navigation": {
            "后台管理": "Back-stage management",
            "工作台": "Workbench",
            "全局视图": "Global View",
            "知识库": "knowledge Base",
            "知识检索": "Knowledge Retrieval",
            "知识录入": "Knowledge Input",
            "运营数据": "Operational Data",
            "服务管理": "Service Management",
            "服务": "Service",
            "服务目录": "Service Catalogue",
            "流程管理": "Process Management",
            "流程设计": "process Design",
            "流程版本": "Process Version",
            "API 配置": "API configuration",
            "SLA管理": "SLA Management",
            "角色配置": "Role Configuration",
            "角色表": "Role Table",
            "通用角色": "General Roles",
            "管理员列表": "Managers",
            "系统配置": "System Configuration",
            "数据字典": "Data Dictionary",
            "基础配置": "Basic Configuration",
            "接口日志": "API Log",
        },
        "newCommon": {
            "请选择所属的厅委办": "Please select the office to which you belong.",
            "请选择所属业务": "Please choose your business",
            "操作": "Operations",
            "添加": "Add",
            "删除": "Delete",
            "选择日期": "Choose a date",
            "选择日期时间": "Choose the date and time",
            "请选择": "Please choose",
            "模板下载": "Template Download",
            "基本信息": "Basic information",
            "节点名称": "Node name",
            "API接口": "API interface",
            "处理时间": "Processing time",
            "节点信息": "Node information",
            "输入参数": "Input parameters",
            "返回变量": "Return variables",
            "变量名": "Variable name",
            "变量值": "Variable value",
            "暂无数据": "No Data",
            "接口返回": "Interface return",
            "当前步骤": "Current step",
            "该单据已结束": "The worksheet is closed",
            "该单据已被终止": "The worksheet has been terminated",
            "您暂无权限处理": "You have no right to handle it",
            "您暂无任务需要处理": "You have no task to process",
            "终止原因": "Causes of termination",
            "终止原因不能为空": "The causes of termination cannot be empty",
            "挂起原因": "Cause of suspension",
            "请输入挂起原因": "Please enter the causes of suspension",
            "挂起原因不能为空": "Causes for suspension can not be empty",
            "转单人": "Assigner",
            "请选择处理人": "Please select the processor",
            "转单人不能为空": "Assigner should not be empty",
            "转单原因": "Reasons for the assignation",
            "转单原因不能为空": "Reasons for the assignation should not be empty",
            "指定处理人": "Appoint processor",
            "请选择指定处理人": "Please select the appointed processor",
            "指定处理人不能为空": "Appointed processor should not be empty",
            "CMDB业务公用角色": "CMDB Business Public Roles",
            "通用角色表": "General role table",
            "个人": "Personal",
            "执行认领操作后，单据将流入我的待办": "After the operation is performed, the worksheet will flow into my to-do worksheets.",
            "执行恢复操作后，单据将可以继续处理": "After the operation is performed, the worksheets can be processed again.",
            "抱歉你暂无该节点的处理权限": "Sorry, you don not have the processing rights of this node for the time being.",
            "工单进度预览": "Preview of worksheet schedule",
            "服务目录": "Service catalogue",
            "提单人": "Submitter ",
            "提单人部门": "Submitter Department",
            "撤单": "Cancel",
            "督办": "Supervise",
            "流程开始": "Process start",
            "流转日志": "Circulation log",
            # '通知关注人': 'Notice focusers',
            "满意度评价": "Satisfaction Evaluation",
            # '关注人': 'Focusers',
            "请添加关注人": "Add focusers",
            "关注信息": "Focus information",
            "发送": "Send",
            "发送历史": "Send History",
            "单据已经处理完成，请对整体单据处理进行评价": "Worksheet have been processed. Please evaluate the overall worksheet processing.",
            "直接评价": "Direct evaluate",
            "邀请评价": "Invitation evaluate",
            "意见": "Opinion",
            "提交": "Submit",
            "手机号码": "Mobil",
            "请输入，多个用英文逗号分隔": "Please enter, separated by English commas",
            "提交后系统会发送信息至需求方进行满意度评价": "After submission, the system will send information to the demander for satisfaction evaluation.",
            "你已发送过满意度评价短信给": "You have sent a short satisfaction evaluation message to ",
            "的用户": "",
            "已评价": "Evaluated",
            "评分": "rate",
            "评价人": "By",
            "提出意见": "Bring up an opinion",
            "这个朋友很懒，什么也没留下": "The friend was lazy and left nothing behind.",
            "知识库": "Knowledge base",
            "关联单据": "Associated worksheet",
            "工单处理": "Worksheet processing",
            "处理人": "Processor",
            "处理操作": "Process operations",
            "请您认领或分派该工单": "Please take or assign the worksheet.",
            "请您分派该工单": "Please assign the worksheet.",
            "请您认领该工单": "Please take the worksheet.",
            "您没有该工单目前节点的操作权限": "You do not have permission to operate on the current node of the worksheet",
            "提交至下一步": "Submit to the next step",
            "保存字段": "Save fields",
            "终止": "Terminate",
            "转处理人": "Assign to other processor",
            "所选分支": "Selected Branch",
            "展开全部": "Expand",
            "收起全部": "Pack up",
            "流程结束": "Process finished",
            "取消": "Cancel",
            "提交后，该流程将强制终止结束，并无法重启。请谨慎操作": "After submission, the process will be forced to terminate and cannot be restarted. Please operate with caution.",
            "提交后单据将退回至相应环节，请确认": "After submission, the worksheet will be returned to the corresponding link, please confirm.",
            "请填写转单原因": "Please fill in the reasons for the assignation.",
            "提交后，单据将会转入新的处理人待办中": "After submission, the worksheet will be assigned to the new processors to be done",
            "确定保存": "Confirm save",
            "确认后仅保存此次更新记录，并不会作为最终处理结果提交到下个环节，且不支持保存富文本和附件的内容": "After confirmation, only this update record will be saved, and will not be submitted to the next step as the final processing result, and the content of rich text and attachments will not be supported.",
            "确认操作": "Confirm operation",
            "提交后，流程将转入下一环节，当前提交内容将无法修改": "After submission, the process will move to the next step, and the current submission content will not be able to be modified.",
            "无字段可以保存": "No field can be saved",
            "保存成功": "Saved successfully",
            "打回至": "Call back to",
            "驳回原因": "Reasons for rejection",
            "请填写驳回原因": "Please fill in the reasons for rejection.",
            "终止流程": "Termina process",
            "请填写终止原因": "Please fill in the reasons for termination.",
            "处理人不能为空": "Processors should not be empty",
            "标题": "Title",
            "打印": "Print",
            "更多操作": "More operations",
            "确认撤销此单据": "Confirm to revoke this worksheet",
            "执行撤单操作后，单据将永久删除": "After the withdrawal operation, the worksheet will be permanently deleted",
            "确认督办该节点": "Confirm to supervise the node",
            "执行督办操作后，将发送信息至处理人": "After executing the supervisory operation, the message will be sent to the processor.",
            "撤单成功": "Revoked successfully",
            "领取成功": "Took successfully",
            "督办成功": "Supervised successfully",
        },
        "serviceConfig": {
            "服务名称": "Service Name",
            "请输入服务名称": "Please enter the service name",
            "关联流程版本": "Associate process version",
            "服务类型": "Service type",
            "服务级别": "Service level",
            "可见范围": "Visible range",
            "请选择": "Please choose",
            "服务描述": "Service description",
            "启用服务": "Enable services",
            "关联目录": "Associate catalogue",
            "确认": "Confirm",
            "取消": "Cancel",
            # '暂无数据': 'No Data',
            "请输入搜索关键字": "Please enter search keywords",
            "新增": "Add",
            "编辑": "Edit",
            "删除": "Delete",
            "父级目录": "Parent directory",
            "目录名称": "Directory name",
            "目录描述": "Directory description",
            "请输入目录名称": "Please enter the directory name",
            "请输入目录描述": "Please enter a directory description",
            "关闭": "Close",
            "添加": "Add",
            "批量移除": "Batch Remove",
            "请输入关键字": "Please enter keywords",
            "服务说明": "Service instructions",
            "操作": "Operations",
            "移除": "Delete",
            "共计": "Total",
            "条": "",
            "每页": "each page",
            "确认移除服务": "Confirm Remove Service",
            "移除后，将无法在该目录下找到该服务，请谨慎操作": "After removal, the service will not be found in this directory. Please operate with caution.",
            "添加服务": "Add services",
            "请至少选择一项服务": "Please choose at least one service.",
            "移除成功": "Removed successfully",
            "添加成功": "Added Successfully",
            "服务": "Service",
            "批量删除": "Batch delete",
            "关联流程": "Associate process",
            "更新时间": "Update time",
            "状态": "Status",
            "启用": "Enable",
            "新增服务": "Add Services",
            "确认删除服务？": "Confirm delete service?",
            "服务一旦删除，对应的服务将不可用。请谨慎操作。": "Once the service is deleted, the corresponding service will not be available. Please operate with caution.",
            "请输入服务名": "Please enter the service name",
            "编辑服务": "Edit Services",
            "删除成功": "Deleted successfully",
            "批量删除成功": "Batch deleted successfully",
        },
        "systemConfig": {
            "指定查询的字段，参数为业务的任意属性，如果不填写字段信息，系统会返回业务的所有字段": "Specify the field of the query, and the parameters are any attributes of the business. If the field information is not filled in, the system will return all the fields of the business.",
            "查询条件，参数为业务的任意属性，如果不写代表搜索全部数据": "Query conditions, parameters are arbitrary attributes of the business, if not written on behalf of the search for all data",
            "记录开始位置": "Record start position",
            "每页限制条数,最大200": "Limited number of entries per page, up to 200",
            "分页条件": "Paging conditions",
            "初始化数据": "Initialization data",
            "未完成": "Unaccomplished",
            "已完成": "Accomplished",
            "开放接口：": "Open interface:",
            "参数名称": "Parameter name",
            "参数值": "Parameter value",
            "参数示例": "Parameters examples",
            "备注": "Remarks",
            "导入JSON": "Import JSON",
            "必选": "Required",
            "可选": "Optional",
            "模板": "Template",
            "预览": "preview",
            "属性": "Attribute",
            "是否必须": "Required",
            "默认值": "Default values",
            "请输入": "Please enter",
            "请输入默认值": "Please enter the default value",
            "兄弟节点": "Brother Node",
            "子节点": "Subnode",
            "发送": "Send",
            "接口名称：": "Interface name:",
            "创 建 人：": "Founder:",
            "状  态：": "Status:",
            "更新时间：": "Update at:",
            "接口路径：": "Interface Path:",
            "备  注：": "Remarks:",
            "请求参数": "Request parameters",
            "示例": "Examples",
            "暂无数据": "No Data",
            "名称": "Name",
            "类型": "Type",
            "返回数据": "Return data",
            "Mock地址：": "Mock address:",
            "备注：": "Remarks:",
            "基本设置": "Basic settings",
            "返回结果": "Return results",
            "其他": "Other",
            "保存": "Save",
            "更新成功": "Updated Successfully",
            "配置": "Configure",
            "保存样例": " Save samples",
            "保存参数": "Save parameters",
            "请求参数设置": "Request parameter setting",
            "返回数据设置": "Return data settings",
            "其 他": "Others",
            "接口分类": "Interface Classification",
            "接口分类不能为空": "Interface classification cannot be empty",
            "选择接口": "Selecte interface",
            "接口名称": "Interface name",
            "请输入接口名称": "Please enter interface name",
            "接口名称不能为空": "Interface name cannot be empty",
            "函数名称": "Function name",
            "请输入函数名称": "Please enter the function name.",
            "函数名称不能为空": "Function name cannot be empty",
            "接口路径": "Interface Path",
            "版本号": "Version",
            "版本号名称不能为空": "Version name cannot be empty",
            "API描述": "API description",
            "请输入API描述": "Please enter an API description",
            "注：详细的接口数据可以在编辑页面中添加": "Note: Detailed interface data can be added to the edit page",
            "确认": "Confirm",
            "取消": "Cancel",
            "添加成功": "Added Successfully",
            "启用状态": "Enabled status",
            "编码": "Code",
            "请输入编码": "Enter the code.",
            "请输入名称": "Please enter the name",
            "描述": "describe",
            "请输入描述": "Please enter the description.",
            "添加": "Add",
            "名字": "Name",
            "父级": "Parents",
            "操作": "Operations",
            "删除": "Delete",
            "父级：": "Parents:",
            "请选择": "Please choose",
            "编码：": "Code:",
            "请输入编码，格式为英文数字及下划线": "Please enter the encoding in English numerals and underlines.",
            "编码格式为英文数字及下划线": "The encoding format is English numerals and underlines.",
            "名称：": "Name:",
            "请输入中文名称": "Please enter a name in Chinese.",
            "新增字典数据": "New dictionary data",
            "确认删除该条数据？": "Confirm delete this data?",
            "被删除的数据将不可恢复，请谨慎操作。": "The deleted data will not be recoverable. Please operate with caution.",
            "编辑字典数据": "Edit dictionary data",
            "删除成功": "Delete successfully",
            "父级目录不能是自己！": "The parent directory can not be itself!",
            "编辑": "Edit",
            "运行": "Run",
            "全部系统": "All systems",
            "点击上传": "Click Upload",
            "导入": "Import",
            "添加接口": "Add interfaces",
            "批量移除": "Batch Remove",
            "请输入关键字": "Please enter keywords",
            "状态": "status",
            "接入数量": "Access numbers",
            "导出": "Export",
            "移除": "Remove",
            "共计": "Total",
            "条": "",
            "每页": "each page",
            "API列表": "API List",
            "确认移除服务？": "Confirm to remove service?",
            "移除后，将无法使用该接口，请谨慎操作": "After removal, the interface will not be available. Please operate with caution.",
            "批量删除成功": "Batch delete successfully",
            "成功导入": "Successfully import",
            "个API接口，": "API interface,",
            "失败": "",
            "个": "Failed",
            "文件大小不能超过10MB！": "File size should not exceed 10MB!",
            "请输入搜索关键字": "Please enter search keywords",
            "接入系统": "Access in system",
            "系统名称：": "System name:",
            "修改系统": "Modify the system",
            "系统名称不能为空": "System name cannot be empty",
            "负责人：": "Header:",
            "系统负责人不能为空": "System header Can not Be Empty",
            "请输入备注": "Please enter remarks",
            "启用：": "Enable:",
            "打开": "Open",
            "关闭": "Close",
            "确认移除系统？": "Confirm to remove system?",
            "移除后，将无法使用该系统，请谨慎操作": "After removal, the system will not be able to be used. Please operate with caution.",
            "修改成功": "Revised successfully",
            "分类名称": "Category name",
            "请输入分类名称": "Please enter the category name.",
            "分类描述": "Classification description",
            "请输入分类描述": "Please enter a classification description.",
            "启用分类": "Enable Classification",
            "基本信息": "Basic information",
            "接口地址": "Interface Address",
            "请求方法": "Request method",
            "请求时间": "Request time",
            "耗时": "Time consuming",
            "接口ID": "Interface ID",
            "单据ID": "Document ID",
            "节点ID": "Node ID",
            "API 配置": "API configuration",
            "数据字典": "Data dictionary",
            "新增": "Add",
            "批量删除": "Batch delete",
            "更新人": "Updater",
            "有效": "valid",
            "无效": "invalid",
            "新增字典": "New dictionary",
            "确认删除此数据字典？": "Confirm to delete this data dictionary?",
            "数据字典一旦删除，此数据字典将不可用。请谨慎操作。": "Once the data dictionary is deleted, the data dictionary will not be available. Please operate with caution.",
            "编辑字典": "Editing Dictionary",
            "流程版本": "Process version",
            "批量导出": "Batch export",
            "查看": "check",
            "请输入接口地址": "Please enter the interface address",
            "状态码": "Status code",
            "日志详情": "Log details",
        },
        "treeinfo": {
            "新增字段": "New fields",
            "字段名": "Field name",
            "字段类型": "Field type",
            "字段值": "Field value",
            "字段描述": "Field description",
            "字段校验方式": "Field Verification Method",
            "布局要求": "Layout requirements",
            "字段属性": "Field properties",
            "操作": "Operations",
            "自定义": "Custom",
            "默认": "Default",
            "上移": "Move upward",
            "下移": "Move down",
            "编辑": "Edit",
            "删除": "Delet",
            "暂无数据": "No Data",
            "字段预览": "Field Preview",
            "确认删除此字段？": "Confirm to delete this field?",
            "字段一旦删除，此字段将不在可用。请谨慎操作。": "Once the field is deleted, it will not be available. Please operate with caution.",
            "编辑字段": "Edit fields",
            "删除成功": "Deleted successfully",
            "开始": "Start",
            "结束": "End",
            "节点配置": "Node Configuration",
            "新增节点": "New Nodes",
            "配置": "Configure",
            "手动节点": "Manual Node",
            "API节点": "API Node",
            "标准运维节点": "Sops Node",
            "汇聚网关": "Convergence Gateway",
            "并行网关": "Parallel Gateway",
            "开始节点": "Start Node",
            "结束节点": "End Node",
            "线条配置": "Line configurate",
            "确认删除": "confirm deletion",
            "确认后，此节点将从该流程中移除！": "After confirmation, this node will be removed from the process!",
            "开始节点只能单一输出！": "Start node can only output single!",
            "开始节点只能输出！": "Start node can only output!",
            "结束节点只能输入！": "End node can only be entered!",
            "开始节点和结束节点不能直接相连！": "The start node and the end node are not directly connected!",
            "自身不能相连！": "You can not connect yourself!",
            "已存在的连线！": "Existing connections!",
            "名称": "Name",
            "必选": "Required",
            "备注": "Remarks",
            "参数值": "Parameter values",
            "是": "Yes",
            "否": "No",
            "请输入参数值": "Please enter parameter values",
            "添加变量": "Adding variables",
            "引用变量": "Reference variable",
            "请选择数据来源": "Please select the data source",
            "是否必须": "Is it required?",
            "类型": "Type",
            "初始化数据": "Initialization data",
            "选取值": "Select value",
            "选取数组": "Select arrays",
            "关键字字段": "Keyword field",
            "显示字段": "Display field",
            "请输入名称": "Please enter a name",
            "请输入关键字": "Please enter keywords",
            "请输入GET参数！": "Please enter GET parameters!",
            "请输入POST参数！": "Please enter POST parameters!",
            "请选择返回数据": "Please select the return data",
            "请选择接入系统": "Please select Access System",
            "请选择接口": "Please select the interface",
            "请输入值，Enter分隔": "Please enter the value,separated by Enter",
            "请输入测试数据地址": "Please enter the test data address",
            "请选择": "Please choose",
            "前置节点": "Pre-node",
            "唯一标识": "Unique identifier",
            "请输入唯一标识": "Please enter a unique identifier",
            "校验方式": "Verification method",
            "正则规则": "Regularity",
            "请输入正则规则": "Please enter the regularity",
            "数据源": "Data source",
            "自定义数据": "Custom data",
            "请输入，Enter分隔": "Please enter the value,separated by Enter",
            "上传附件模板": "Upload attachment template",
            "点击上传": "Click to upload",
            "字段必填": "Field must be filled in",
            "填写说明": "Fill instructions",
            "请输入字段填写说明": "Please enter the fields to fill in the instructions.",
            "添加额外提示说明": "Add additional instructions",
            "字段释疑": "Field Explanation",
            "效果预览": "Effect Preview",
            "字段释疑填填看哦": "Fill in the field explanation",
            "请输入，用于鼠标经过提示": "Please enter, for the mouse to pass through the prompt",
            "提交": "Submit",
            "取消": "Cancel",
            "请选择表现形式": "Please choose the form of expression.",
            "输入框": "Input",
            "选择框": "Selection",
            "无": "Nothing",
            "此文件已经上传": "This file has been uploaded",
            "上传成功": "Uploaded Successfully",
            "该文件大小超过100MB！": "The file size is over 100MB!",
            "字段名已存在": "The field name already exists",
            "修改成功": "Revised successfully",
            "新增成功": "Added successfully",
            "轮询配置": "Polling configuration",
            "当出现异常时，设置重试及结束的条件": "When an exception occurs, set conditions for retry and termination",
            "开启轮询": "Open polling",
            "打开": "Open",
            "关闭": "Close",
            "条件组间关系": "Conditional intergroup relations",
            "当所有条件组都满足且/或的条件组时，轮询才会结束": "Polling ends when all condition groups satisfy and/or condition groups",
            "且": "And",
            "或": "Or",
            "字段间关系": "Inter-field relationship",
            "请输入比较值": "Please enter a comparison value",
            "关系组内的数据不能为空": "Data in a relational group cannot be empty",
            "添加条件组": "Adding conditional groups",
            "轮询间隔": "Polling interval",
            "请输入间隔时间": "Please enter the interval time",
            "轮询次数": "Number of polls",
            "请输入轮询次数": "Please enter the number of polls",
            "上一步": "Previous",
            "下一步": "Next",
            "保存": "Save",
            "保存成功": "Saved successfully",
            "流程启用设置": "Process enablation settings",
            "填写流程信息": "Fill in process information",
            "请输入字段显示名": "Please enter the field display name",
            "是否必填": "Required",
            "引用为全局变量": "Refer to global variables",
            "调用该API需要传递的参数信息": "The parameter information that needs to be passed to invoke the API",
            "请输入变量名": "Please enter a variable name",
            "请选择前置节点": "Please select the leading node",
            "字段名称": "Field name",
            "请输入字段名称": "Please enter the field name",
            "字段布局": "field layout",
            "校验条件": "Check conditions",
            "时间范围": "time range",
            "请输入字段描述": "Please enter a field description",
            "节点一": "Node 1",
            "节点二": "Node 2",
            "节点三": "Node 3",
            "文本输入框": "Text input",
            "下拉框": "Selecctor",
            "多选框": "Checkbox",
            "时间": "Time",
            "负责人": "Person in charge",
            "业务": "Business",
            "流程启用": "Process enablation",
            "是否启用该流程：": "Enabled",
            "流程部署": "Process deployment",
            "是否立即部署流程：": "Deploy the process immediately?",
            "部署流程名：": "Name of deployment process:",
            "请输入部署流程名": "Please enter the name of the deployment process",
            "部署流程名不能为空": "Name of deployment process cannot be empty",
            "设置任务通知策略": "Setting Task Notification Policy",
            "是否通知：": "Notify:",
            "是否督办：": "Supervise:",
            "默认督办人：提单人": "Default supervisor: Submitter",
            "其他督办人：": "Other supervisors:",
            "通知频率：": "Notification frequency:",
            "首次通知，以后不再通知": "Just first-time",
            "首次通知后，次日起每天定时通知": "Once per day after the first notification",
            "通知类型：": "Type of notification:",
            "SMS短信": "SMS Message",
            "邮件": "Mail",
            "微信": "weChat",
            "流程部署成功，是否去服务页面关联此流程": "Process deployed successfully ,go to the service page to associate this process",
            "定义与配置流程": "Definite and configurate process",
            "基本信息": "Basic information",
            "节点名称": "Node name",
            "请输入节点名称": "Please enter the node name",
            "API接口": "API interface",
            "失败处理人": "Failure processor",
            "输入参数": "Input parameters",
            "返回数据": "Return data",
            "调用成功后API将会返回的参数信息": "The parameter information that will be returned by API after successful invocation",
            "确定": "Define",
            "请完善轮询配置！": "Please improve polling configuration!",
            "请完善轮询间隔、次数！": "Please improve polling interval and frequency!",
            "请填写节点名称！": "Please fill in the node name!",
            "请选取接口！": "Please select the interface!",
            "勾选全局变量后，请提供变量名": "After checking the global variable, please provide the variable name",
            "节点名称：": "Node name:",
            "请输入节点名称,最多输入8个字符": "Please enter the node name, up to 8 characters",
            "处理场景：": "Processing scenarios:",
            "派单人：": "Distributor ",
            "处理人：": "Processor:",
            "是否可转单：": "Assignable",
            "请选择转单人，默认可以转给任何人": "Please select the assigner, which can be assgined to anyone by default.",
            "转单人：": "Assigner:",
            "是否可终止：": "Terminatable",
            "指该节点动作需要通过派单人分派到指定处理人或者处理角色，被分派到的处理人再进行处理。": "The action of the node needs to be handled by distributor to a assgined processor or a processing role, and then by the dispatched processor.",
            "单据直接流入到配置好的处理人/角色处理。当有多个处理人时，任何一位处理完成即可流入下个环节。": "Worksheet flow directly into the configured handler/role processing. When there are multiple processors, any one of them can flow into the next step.",
            "指配置好的处理人/角色人员需要主动认领任务。当处理人只有1位时，会自动认领。处理人有2人及以上时，需要主动认领至自己的待办任务中。": "It refers to the disposition of the disposer/role personnel need to take the initiative to take the task. When the handler has only one person, it will automatically took. When there are two or more handlers, they need to take the initiative to take to their own to-do tasks.",
            "单据需要派单人进行指派到组或者多人，然后被指派对象进行主动认领。认领完成后才会到自己的待办任务列表中。": "Worksheet need to be assigned by a distributor to a group or more people, and then be assigned to the object for active take. After the taking is completed, it will go to its to-do list.",
            "直接处理": "Direct process",
            "派单人指定": "Appoint Distributor",
            "字段配置": "Field configuration",
            "布局": "layout",
            "半行": "Half line",
            "（使用模版可以快速填写）": "(Template can be used to fill in quickly)",
            "关系模板": "Relation Template",
            "流转条件": "Conversion Conditions",
            "关系名称": "Relation Name",
            "请输入关系名称": "Please enter the relation name",
            "关系名称不能为空": "Relation name cannot be empty",
            "当所有条件组都满足且/或的条件时，节点才会流转": "Nodes flow only when all condition groups satisfy and/or conditions.",
            "-条件组": "- Conditional group",
            "确认": "Confirm",
            "更新模板": "Update template",
            "存为模版": "Save as a template",
            "配置成功！": "Configurated successfully!",
            "保存成功！": "Saved successfully!",
            "流程/原子": "Process/Atom",
            "请选择流程/原子": "Please select process/atom",
            "任务未执行，无法查看": "Task not executed, unable to view",
            "已通过": "Passed",
            "被终止": "Terminated",
        },
        "user": {
            "角色管理员": "Role administrator",
            "角色名": "Role name",
            "权限页面": "Permission page",
            "人员": "Members",
            "说明": "Instructions",
            "操作": "Operations",
            "统计配置": "Statistical configuration",
            "超级管理员": "Super administrator",
            "编辑": "Edit",
            "保存": "Save",
            "删除": "Delete",
            "暂无数据": "No Data",
            "提交": "Submit",
            "取消": "Cancel",
            "新增管理员": "Add administrator",
            "角色名：": "Role name:",
            "请输入自定义角色名称": "Please enter a custom role name",
            "说明：": "Instructions:",
            "请填写角色说明，最多能输入128个字": "Please fill in the role instructions. You can enter 128 words at most.",
            "至少输入5个字": "Enter at least five words",
            "人员：": "Members:",
            "权限操作页：": "Permission operation page:",
            "确认要删除此角色？": "Are you sure you want to delete this role?",
            "角色一旦删除，该角色下的用户权限将失效，谨慎操作。": "Once the role is deleted, the user rights under the role will be invalidated and operated with caution.",
            "删除成功": "Successful deletion",
            "名称不能为空！": "The name cannot be empty!",
            "权限页面不能为空！": "The permission page cannot be empty!",
            "人员不能为空！": "Personnel can not be empty!",
            "描述不能为空！": "Description can not be empty!",
            "描述不能少于5个字！": "Description should not be less than 5 words!",
            "描述不能超过128个字！": "Description should not exceed 128 words!",
            "请完善要填写的信息！": "Please complete the information to be filled in!",
            "角色表": "Role table",
            "角色类型": "Role type",
            "管理": "Administration",
            "缓存更新完毕": "Cache update completed",
            "通用角色": "General roles",
            "新增通用角色": "New general roles",
            "已有通用角色：": "Common roles already exist:",
            "角色名称：": "Role name:",
            "人员名单：": "Member list",
        },
        "wiki": {
            "您没有权限访问该工单！": "You do not have permission to access the worksheet!",
            "没找到页面！": "No page found!",
            "找不到业务！": "No business found!",
            "工作台": "Workbench",
            "全局视图": "Global view",
            "变更管理": "Change Management",
            "事件管理": "Incident Management",
            "问题管理": "Problem management",
            "请求管理": "Request management",
            "知识检索": "Knowledge Retrieval",
            "知识录入": "Knowledge input",
            "运营数据": "Operational data",
            "管理": "Administration",
        },
    }[mod]


if __name__ == "__main__":
    for root in os.listdir("."):
        for next_root, dirs, files in os.walk(root):
            translate_file(
                root,
                next_root,
                files,
                [
                    "serviceConfig",
                    "flowManager",
                    "systemConfig",
                    "treeinfo",
                    "navigation",
                    "managePage",
                    "home",
                    "deployPage",
                    "common",
                    "newCommon",
                    "user",
                    "wiki",
                ],
            )
            # print root, next_root, dirs, files
